<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>演示DOM操作</title>
</head>
<body>

<h3>添加品牌</h3>
<form action="" method="post">
    品牌名称：<input id="brandName" name="brandName"><br>
    企业名称：<input id="companyName" name="companyName"><br>
    排序：<input id="ordered" name="ordered"><br>
    描述信息：
    <textarea rows="5" cols="20" id="description" name="description"></textarea><br>
    状态：
    <input type="radio" name="status" value="0">禁用
    <input type="radio" name="status" value="1">启用<br>

    <input id="btn" type="button" value="提交" onclick="postBrand()">
</form>

<script>
    function postBrand() {
        let brand = {
            brandName: "",
            companyName: "",
            ordered: "",
            description: "",
            status: ""
        };

        // 3.获取品牌输入框中的数据,放到brand对象中
        brand.brandName = document.getElementById("brandName").value;
        brand.companyName = document.getElementById("companyName").value;
        brand.ordered = document.getElementById("ordered").value;
        brand.description = document.getElementById("description").value;

        let statuses = document.getElementsByName("status");
        for (let st of statuses) {
            if (st.checked) {
                brand.status = st.value;
            }
        }

        alert(brand.brandName + ": " + brand.companyName + ": " + brand.ordered + ": " + brand.description);
    }
</script>
</body>
</html>